#include <cstdio>

using namespace std;

typedef unsigned long long ull;
const ull inv3=12297829382473034411LLU;

ull read() {
    ull ret=0;
    char c;
    for (c=getchar(); c<'0' || c>'9'; c=getchar());
    for (; c>='0' && c<='9'; c=getchar()) ret=ret*10+c-'0';
    return ret;
}

ull s(ull n, int k) {
    if (k==1) return n%2 ? (n+1)/2*n : n/2*(n+1);
    else if (k==2) return n%2 ? (n+1)/2*n*(2*n+1)*inv3 : n/2*(n+1)*(2*n+1)*inv3 ;
    else if (k==3) return n%2 ? (n+1)/2*(n+1)/2*n*n : n/2*n/2*(n+1)*(n+1);
    else return n;
}

ull sn(ull a, ull b, int k) {return a>0 ? s(b, k)-s(a-1, k) : s(b, k);}

ull calcSqu(ull x, ull y) {
    ull n;
    if (x==0) {
        return 4*s(y, 2)+3*s(y, 1)+y+1;
    } else if (x-1==y) {
        return 8*s(y, 3)+16*s(y, 2)+11*s(y, 1)+3*(y+1);
    } else if (x-1<y) {
        n = x-1;
        return 8*s(n, 3)+16*s(n, 2)+11*s(n, 1)+3*(n+1)
            + (n+2)*(4*sn(n+1, y, 2)+3*sn(n+1, y, 1)+(y-n)) + (y-n)*s(n+1, 1);
    } else {
        n = y;
        return 8*s(n, 3)+16*s(n, 2)+11*s(n, 1)+3*(n+1)
            + (n+1)*(4*sn(n+2, x, 2)-3*sn(n+2, x, 1)+(x-n-1)) - (x-n-1)*s(n, 1);
    }
}

int main() {
    freopen("qiu.in", "r", stdin);
    freopen("qiu.out", "w", stdout);

    int q=read();
    for (int i=1; i<=q; i++) {
        ull x1=read(), x2=read(), y1=read(), y2=read(), ans=calcSqu(x2, y2);
        if (x1) ans-=calcSqu(x1-1, y2);
        if (y1) ans-=calcSqu(x2, y1-1);
        if (x1 && y1) ans+=calcSqu(x1-1, y1-1);
        printf("%llu\n", ans%(1LLU<<63));
    }

    fclose(stdin);
    fclose(stdout);
    return 0;
}
